<template>
  <view class="b_cus_info_add_container">
    <view class="example">
      <uni-forms ref="form" :model="form" labelWidth="80px">
    <uni-forms-item label="客户编码" name="bCusCode" required >
      <uni-easyinput v-model="form.bCusCode" placeholder="请输入客户编码" />
    </uni-forms-item>
    <uni-forms-item label="客户名称" name="bCusName" required >
      <uni-easyinput v-model="form.bCusName" placeholder="请输入客户名称" />
    </uni-forms-item>
    <uni-forms-item label="法定代表人" name="bCusLegalPerson"  >
      <uni-easyinput v-model="form.bCusLegalPerson" placeholder="请输入法定代表人" />
    </uni-forms-item>
    <uni-forms-item label="身份证号" name="bCusIdcard"  >
      <uni-easyinput v-model="form.bCusIdcard" placeholder="请输入身份证号" />
    </uni-forms-item>
    <uni-forms-item label="工商注册号" name="bCusRegCode"  >
      <uni-easyinput v-model="form.bCusRegCode" placeholder="请输入工商注册号" />
    </uni-forms-item>
    <uni-forms-item label="联系电话" name="bCusPhone" required >
      <uni-easyinput v-model="form.bCusPhone" placeholder="请输入联系电话" />
    </uni-forms-item>
    <uni-forms-item label="电子邮箱" name="bCusEmail"  >
      <uni-easyinput v-model="form.bCusEmail" placeholder="请输入电子邮箱" />
    </uni-forms-item>
    <uni-forms-item label="客户地址" name="bCusAddr"  >
      <uni-easyinput v-model="form.bCusAddr" placeholder="请输入客户地址" />
    </uni-forms-item>
    <uni-forms-item label="客户等级" name="bCusLevel"  >
      <uni-easyinput v-model="form.bCusLevel" placeholder="请输入客户等级" />
    </uni-forms-item>
    <uni-forms-item label="创建人" name="bCreateUser" required >
      <uni-easyinput v-model="form.bCreateUser" placeholder="请输入创建人" />
    </uni-forms-item>
  <uni-forms-item label="创建时间" name="bCreateTime" required >
    <uni-datetime-picker type="datetime" v-model="form.bCreateTime" return-type="string" />
  </uni-forms-item>
    <uni-forms-item label="更新人" name="bUpdateUser"  >
      <uni-easyinput v-model="form.bUpdateUser" placeholder="请输入更新人" />
    </uni-forms-item>
  <uni-forms-item label="更新时间" name="bUpdateTime" required >
    <uni-datetime-picker type="datetime" v-model="form.bUpdateTime" return-type="string" />
  </uni-forms-item>
  <uni-forms-item label="备注信息" name="bRemark"  >
  <uni-easyinput type="textarea" v-model="form.bRemark" placeholder="请输入备注信息" />
  </uni-forms-item>

      </uni-forms>
      <view class="button-group">
        <button type="default" style="padding:0 3em;font-size:14px"  class="button" @click="reset">重置</button>
        <button type="primary" style="padding:0 3em;font-size:14px"  class="button" @click="submit">提交</button>
      </view>
    </view>
  </view>
</template>


<script>
    import { addBCusInfo,getBCusInfo,listBCusInfo } from "@/api/cust/BCusInfo";
    import {getSelectDict} from "@/utils/dict";
export default {
components: {
},
data() {
  return {
    //字典类型筛选options
    form: {},
    rules: {
            bCusCode: {
                rules: [{ required: true, errorMessage: "客户编码不能为空" }]
            },
            bCusName: {
                rules: [{ required: true, errorMessage: "客户名称不能为空" }]
            },
            bCusType: {
                rules: [{ required: true, errorMessage: "客户类型不能为空" }]
            },
            bCusPhone: {
                rules: [{ required: true, errorMessage: "联系电话不能为空" }]
            },
            bCreateUser: {
                rules: [{ required: true, errorMessage: "创建人不能为空" }]
            },
            bCreateTime: {
                rules: [{ required: true, errorMessage: "创建时间不能为空" }]
            },
            bUpdateTime: {
                rules: [{ required: true, errorMessage: "更新时间不能为空" }]
            },
    }
  }
},
onLoad(option) {
  //字典类型查询
},
onReady() {
  this.$refs.form.setRules(this.rules)
},
methods: {
  /* 提交*/
  submit() {
    console.log(this.form)
    this.$refs.form.validate().then(res => {
      addBCusInfo(this.form).then(response => {
        this.$modal.msgSuccess("新增成功")
        setTimeout(() => {
          // 返回到上一级父页面
          this.$tab.navigateBack();
        },500)
      })
    })
  },
  /* 表单重置*/
  reset(){
    this.form = {
       bCusId: undefined,
       bCusCode: undefined,
       bCusName: undefined,
       bCusType: undefined,
       bCusLegalPerson: undefined,
       bCusIdcard: undefined,
       bCusRegCode: undefined,
       bCusPhone: undefined,
       bCusEmail: undefined,
       bCusAddr: undefined,
       bCusLevel: undefined,
       bCusStatus: undefined,
       bCreateUser: undefined,
       bCreateTime: undefined,
       bUpdateUser: undefined,
       bUpdateTime: undefined,
       bRemark: undefined
    };
  }
}
}
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .b_cus_info_add_container {
    .example {
      padding: 15px;
      background-color: #fff;
    }

    .button-group {
      margin-top: 15px;
      display: flex;
      justify-content: space-around;
    }
  }
</style>